package com.course.service.impl;

import com.course.entity.ResultBody;
import com.course.mapper.SubjectMapper;
import com.course.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SubjectServiceImpl implements SubjectService {
    @Autowired
    private SubjectMapper subjectMapper;
    @Override
    public ResultBody addsubject(Map<String,Object> map) {
        if(subjectMapper.addsubject(map)>0&&subjectMapper.assginourse(map)>0)
        {
            return new ResultBody(200,"添加成功",true);
        }
        else
            return new ResultBody(500,"添加失败",false);
    }
    @Override
    public ResultBody delsubject(Map<String,Object> map) {
        if(subjectMapper.delteach(map)>0&&subjectMapper.delsubject(map)>0)
        {
            return new ResultBody(200,"删除成功",true);
        }
        else
            return new ResultBody(500,"删除失败",false);
    }
    @Override
    public ResultBody updatesubject(Map<String,Object> map) {
        if(subjectMapper.updatesubject(map)>0&&subjectMapper.updateteach(map)>0)
        {
            return new ResultBody(200,"更新成功",true);
        }
        else
            return new ResultBody(500,"更新失败",false);
    }
    @Override
    public ResultBody displaysubject() {
        if(subjectMapper.displaysubject()!=null||subjectMapper.displaysubject()==null)
        return new ResultBody(200,"展示信息成功",subjectMapper.displaysubject(),subjectMapper.displaysubject().size());
        else
            return new ResultBody(500,"展示信息失败",false);
    }
}
